package com.jiangruan.javaproject.Bigjob;

import com.jiangruan.javaproject.service.*;

import java.util.Scanner;

/**
 * @author:xulonghua
 * @email:3162193565@qq.com
 * @desc:该功能用于封装了比特币客户端与RPC通信
 * @datetime 2021/12/26 23:44
 */
public class RpcBitcoin {
    public void rpcbitcoin(){
        while (true){
            Scanner scanner = new Scanner ( System.in );
            System.out.println ("1.获取链头区块哈希");
            System.out.println ("2.获取指定哈希的区块");
            System.out.println ("3.获取区块数量");
            System.out.println ("4.获取指定高度区块的哈希");
            System.out.println ("5.获取出块难度");
            System.out.println ("6.获取指定哈希区块头");
            System.out.println ("0.退出");
            int i = scanner.nextInt ();
            switch (i){
                case 1:
                    GetBestBlockHash blockHash = new GetBestBlockHash ();
                    System.out.println ( blockHash.getbestblockhash ().getResult ());
                    break;
                case 2:
                    GetBlock block = new GetBlock ();
                    String blcokhash="00000000b3322c8c3ef7d2cf6da009a776e6a99ee65ec5a32f3f345712238473";
                    System.out.println (block.getblock (blcokhash).getResult ());
                    break;
                case 3:
                    GetBlockCount count = new GetBlockCount ();
                    System.out.println (count.getblockcount ( 1001 ).getResult ());
                    break;
                case 4:
                    GetBlockHash getBlockHash = new GetBlockHash ();
                    System.out.println (getBlockHash.getblockhash ( 1001,24554 ).getResult ());
                    break;
                case 5:
                    GetDifficulty getDifficulty = new GetDifficulty ();
                    System.out.println (getDifficulty.getdifficulty ( 1001 ).getResult ());
                    break;
                case 6:
                    GetBlockHeader getBlockHeader = new GetBlockHeader ();
                    String HeaderHash="00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09";
                    System.out.println (getBlockHeader.getblockheader ( 1001,HeaderHash,false ).getResult ());
                    break;
                 default:
                     System.out.println ("输入正确的功能编号");
            }
        }
    }

}
